﻿<Window x:Class="eNursePHR.userInterfaceLayer.WindowOutcomes"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Plan/Evaluate outcomes" SizeToContent="WidthAndHeight"
    xmlns:dc="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.DateControls;assembly=J832.Wpf.BagOTricksLib"
    xmlns:ui="clr-namespace:eNursePHR.userInterfaceLayer"
    Loaded="Window_Loaded"
  >
	<Window.Resources>

		<ui:RemoveParentesisOutcomeConceptConverter x:Key="RemoveParentesisOutcomeConceptConverter" />






		<DataTemplate x:Key="OutcomeTemplatePlan">
			<StackPanel Orientation="Horizontal">
				<TextBlock Text="will" Margin="0,0,5,0" />
				<TextBlock Text="{Binding Path=Concept, Converter={StaticResource RemoveParentesisOutcomeConceptConverter}}"
					ToolTip="{Binding Path=Definition}" Margin="0,0,5,0" />
				 <Image x:Name="imgOutcomeType3" Width="15" Height="15"  />
			</StackPanel>
		
			<DataTemplate.Triggers >
				<DataTrigger Binding="{Binding Path=Code}" Value="1">
					<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Improved.png" />
				</DataTrigger>

				<DataTrigger Binding="{Binding Path=Code}" Value="2">
					<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Stabilized.png" />
				</DataTrigger>

				<DataTrigger Binding="{Binding Path=Code}" Value="3">
					<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Worsened.png" />
				</DataTrigger>
			</DataTemplate.Triggers>

		</DataTemplate>


		<DataTemplate x:Key="OutcomeTemplateEvaluate">
			<StackPanel Orientation="Horizontal">
				<TextBlock Text="is" Margin="0,0,5,0" />
				<TextBlock Text="{Binding Path=Concept}"
					ToolTip="{Binding Path=Definition}" Margin="0,0,5,0" />
				 <Image x:Name="imgOutcomeType4" Width="15" Height="15"  />
			</StackPanel>

			<DataTemplate.Triggers >
				<DataTrigger Binding="{Binding Path=Code}" Value="1">
					<Setter TargetName="imgOutcomeType4" Property="Source" Value="Outcome Types\Improved.png" />
				</DataTrigger>

				<DataTrigger Binding="{Binding Path=Code}" Value="2">
					<Setter TargetName="imgOutcomeType4" Property="Source" Value="Outcome Types\Stabilized.png" />
				</DataTrigger>

				<DataTrigger Binding="{Binding Path=Code}" Value="3">
					<Setter TargetName="imgOutcomeType4" Property="Source" Value="Outcome Types\Worsened.png" />
				</DataTrigger>
			</DataTemplate.Triggers>

		</DataTemplate>




		<DataTemplate x:Key="ccOutcomeTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="0.5*" />
					<ColumnDefinition Width="0.5*" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition />
				</Grid.RowDefinitions>

				<Border Grid.Column="0" Margin="5" BorderBrush="CadetBlue" CornerRadius="5" BorderThickness="1" Padding="5">
					<StackPanel>
						<TextBlock Margin="5" Text="Plan" HorizontalAlignment="Center" FontSize="15" FontWeight="Heavy" />
					<Label Content="Outcome" FontWeight="UltraBold" />
						<ComboBox x:Name="cbOutcomePlan" Width="125" HorizontalAlignment="Left"
						ItemTemplate="{StaticResource OutcomeTemplatePlan}" SelectedValue="{Binding Path=ExpectedOutcome}" SelectedValuePath="Code" />
						<Label Content="Goal" FontWeight="UltraBold" />
						<TextBox Text="{Binding Path=ExpectedGoal, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" />
						<Label Content="Date" FontWeight="UltraBold" />
						<dc:DatePicker Grid.Column="1" Grid.Row="2" Width="100" HorizontalAlignment="Left" Value="{Binding Path=ExpectedDate}" VerticalAlignment="Center"/>
				</StackPanel>
				</Border>


				<Border Grid.Column="1" Margin="5" BorderBrush="CadetBlue" CornerRadius="5" BorderThickness="1" Padding="5">
				<StackPanel >
					<TextBlock Margin="5" Text="Evaluate" HorizontalAlignment="Center" FontSize="15" FontWeight="Heavy" />
					<Label Content="Actual outcome" FontWeight="UltraBold" />
					<ComboBox x:Name="cbOutcomeEvaluate" Width="125" HorizontalAlignment="Left" 
					ItemTemplate="{StaticResource OutcomeTemplateEvaluate}" SelectedValue="{Binding Path=ActualOutcome}" SelectedValuePath="Code" />
				    <Label Content="Evaluation" FontWeight="UltraBold"/>
				    <TextBox Text="{Binding Path=ActualEvaluation, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" VerticalAlignment="Center"/>
				    <Label Content="Date" FontWeight="UltraBold" />
			    	<dc:DatePicker Grid.Column="1" Grid.Row="4" Width="100" HorizontalAlignment="Left" Value="{Binding Path=ActualDate}" VerticalAlignment="Center"/>

				</StackPanel>
			  </Border>

			</Grid>

		
		</DataTemplate>


	</Window.Resources>
		<StackPanel x:Name="spOutcome">
		<StackPanel Orientation="Horizontal">
			<ToolBarTray >
			<ToolBar>
					<Button x:Name="btnSave" Click="btnSave_Click">
						<Image Source="Images\Save.png" Height="15" ToolTip="Save outcomes" />
					</Button>

					<Button x:Name="btnNewOutcome" Click="btnNewOutcome_Click">
					<Image Source="Images\New.png" Height="15" ToolTip="New outcome" />
				</Button>
				<Button x:Name="btnDeleteOutcome" Click="btnDeleteOutcome_Click">
					<Image Source="Images\Delete.png" Height="15" ToolTip="Delete selected outcome"/>
				</Button>
			</ToolBar>
		</ToolBarTray>
			<!--<Border BorderBrush="CadetBlue" BorderThickness="1" CornerRadius="5" Width="220" Padding="5" Margin="5">-->
				<StackPanel Margin="5,0,0,0">
					<TextBlock Text="{Binding Path=Concept}" Foreground="{StaticResource DiagnosisColor}" 
				ToolTip="{Binding Path=Definition}" VerticalAlignment="Center"  TextWrapping="Wrap" FontWeight="UltraBold"/>
				<TextBlock Text="{Binding Path=Comment}" FontStyle="Italic" TextWrapping="Wrap" />
				</StackPanel>
			<!--</Border>-->
		</StackPanel>
		
		<ListView x:Name="lvOutcome" IsSynchronizedWithCurrentItem="True" MaxHeight="130"  >
			<ListView.View>
            
            <GridView AllowsColumnReorder="True" >
            
             <GridViewColumn x:Name="gvcExpectedOutcome" Width="50">

             <GridViewColumn.CellTemplate>
               
                 <DataTemplate>
						<Image x:Name="imgOutcomeType3" Width="15" Height="15"  />

											<DataTemplate.Triggers>
												<DataTrigger Binding="{Binding Path=ExpectedOutcome}" Value="1">
													<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Improved.png" />
												</DataTrigger>

												<DataTrigger Binding="{Binding Path=ExpectedOutcome}" Value="2">
													<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Stabilized.png" />
												</DataTrigger>

												<DataTrigger Binding="{Binding Path=ExpectedOutcome}" Value="3">
													<Setter TargetName="imgOutcomeType3" Property="Source" Value="Outcome Types\Worsened.png" />
												</DataTrigger>
											</DataTemplate.Triggers>
				</DataTemplate>
				
             </GridViewColumn.CellTemplate>

              </GridViewColumn>
                        
                        
                <GridViewColumn x:Name="gvcOutcomeExpectedGoal"
                                        Header="Expected goal"
                                        Width="250" 
                                          >

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                     <TextBlock Margin ="0,0,5,0" Text="{Binding Path=ExpectedGoal}" Width="150"  TextWrapping="Wrap"/>
                                 </DataTemplate>
                            </GridViewColumn.CellTemplate>

                        </GridViewColumn>
                
                <GridViewColumn x:Name="gvcOutcomeExpectedDate"
                                        Header="Planned date"
                                        Width="120"
                                          >

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                     <TextBlock Text="{Binding Path=ExpectedDate}"  />
                                 </DataTemplate>
                            </GridViewColumn.CellTemplate>

                </GridViewColumn>

					<GridViewColumn x:Name="gvcActualOutcome" Width="50">

						<GridViewColumn.CellTemplate>

							<DataTemplate>
								<Image x:Name="imgOutcomeType5" Width="15" Height="15"  />

								<DataTemplate.Triggers>
									<DataTrigger Binding="{Binding Path=ActualOutcome}" Value="1">
										<Setter TargetName="imgOutcomeType5" Property="Source" Value="Outcome Types\Improved.png" />
									</DataTrigger>

									<DataTrigger Binding="{Binding Path=ActualOutcome}" Value="2">
										<Setter TargetName="imgOutcomeType5" Property="Source" Value="Outcome Types\Stabilized.png" />
									</DataTrigger>

									<DataTrigger Binding="{Binding Path=ActualOutcome}" Value="3">
										<Setter TargetName="imgOutcomeType5" Property="Source" Value="Outcome Types\Worsened.png" />
									</DataTrigger>
								</DataTemplate.Triggers>
							</DataTemplate>

						</GridViewColumn.CellTemplate>

					</GridViewColumn>
					
					<GridViewColumn x:Name="gvcOutcomeActualEvaluation"
                                        Header="Evaluation"
                                        Width="250" 
                                          >

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                     <TextBlock Margin="0,0,5,0" Width="150" Text="{Binding Path=ActualEvaluation}" TextWrapping="Wrap"/>
                                 </DataTemplate>
                            </GridViewColumn.CellTemplate>

                        </GridViewColumn>
                
                <GridViewColumn x:Name="gvcOutcomeActualDate"
                                        Header="Evaluation date"
                                        Width="120"
                                          >

                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                     <TextBlock Text="{Binding Path=ActualDate}"/>
                                 </DataTemplate>
                            </GridViewColumn.CellTemplate>

                </GridViewColumn>

					<GridViewColumn x:Name="gvcOutcomeHistoryCreatedBy"
                                        Header="Created by"
                                        Width="100"
                                          >

						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Path=History.CreatedBy}"/>
                                 </DataTemplate>
						</GridViewColumn.CellTemplate>

					</GridViewColumn>

					<GridViewColumn x:Name="gvcOutcomeHistoryCreatedDate"
                                        Header="Created"
                                        Width="100"
                                          >

						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Path=History.CreatedDate}"/>
                                 </DataTemplate>
						</GridViewColumn.CellTemplate>

					</GridViewColumn>

					<GridViewColumn x:Name="gvcOutcomeHistoryLastUpdate"
                                        Header="Last update by"
                                        Width="100"
                                          >

						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Path=History.UpdatedBy}"/>
                                 </DataTemplate>
						</GridViewColumn.CellTemplate>

					</GridViewColumn>

					<GridViewColumn x:Name="gvcOutcomeHistoryLastUpdateDate"
                                        Header="Last update"
                                        Width="100"
                                          >

						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Path=History.UpdatedDate}"/>
                                 </DataTemplate>
						</GridViewColumn.CellTemplate>

					</GridViewColumn>



				</GridView>
            </ListView.View>
		</ListView>
		
		<ContentControl x:Name="ccOutcome" ContentTemplate="{StaticResource ccOutcomeTemplate}" />
		
	</StackPanel>
</Window>
